package zyu.qwq.qwq_bungee_plugin;

import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler;

import java.awt.*;

public class PlayerLeaveEvent implements Listener {
    @EventHandler
    public void onPlayerLeave(PlayerDisconnectEvent e){
        ProxiedPlayer p = e.getPlayer();
        String playerName = p.getDisplayName();

        net.md_5.bungee.api.chat.TextComponent msg1 = new TextComponent(playerName);
        msg1.setBold(true);
        msg1.setColor(ChatColor.AQUA);

        TextComponent msg2 = new TextComponent("离开了qwq_神秘小服服，呜————");
        msg1.setBold(false);
        msg2.setColor(ChatColor.DARK_AQUA);

        msg1.addExtra(msg2);

        for (ProxiedPlayer player: ProxyServer.getInstance().getPlayers()){
            player.sendMessage(
                    msg1
            );
        }

    }
}
